import requests
import json
import sys

class Set:
    def train_test():

        data = {
        "x":["algorithm","compname","fov_no","iwinx", "iwinx1", "iwiny","iwiny1"], 
        "y":["err_desc"], 
        "cate_col":["err_desc", "fov_no", "compname"], 
        "num_col":["algorithm", "iwinx", "iwinx1", "iwiny", "iwiny1"], 
        "methods":"train", 
        "customize": "n", 
        "class":[]
        }
        files = {}
        files["file"] = open("./aoi_data_2000.csv", "rb")
        r = requests.post("http://10.120.115.72:8085/train", data=data, files=files)
        print(r.text)

    def pred_test():
        data = {
        "x_data": json.dumps([[128,"R151_1", "FOV01", 312, 366, 66, 95],
                    [64, "sdf", "sdf", 312, 332, 66, 69]]),
        "x_column_list":json.dumps(["algorithm", "compname", "fov_no", "iwinx", "iwinx1", "iwiny", "iwiny1"]),
        "cate_col":["err_desc", "fov_no", "compname"],
        "num_col":["algorithm", "iwinx", "iwinx1", "iwiny", "iwiny1"],
        "model_name":"ENVODMNS"

        }
        r = requests.post("http://10.120.115.72:8085/predict", data=data)
        print(data)
        print(r.text)

    def pred_test_copy():
        data = {"x":{"algorithm":[128],"compname":["R151_1"],"fov_no":"FOV01", "iwinx":312,"iwinx1":366, "iwiny":66,"iwiny1":95},
        "cate_col":["err_desc", "fov_no", "compname"],
        "num_col":["algorithm", "iwinx", "iwinx1", "iwiny", "iwiny1"],
        "model_name":"ENVODMNS"

        }
        r = requests.post("http://10.120.115.72:8085/predict", data=data)
        print(data)
        print(r.text)

if __name__=="__main__":
    fun = getattr(Set, sys.argv[1])
    fun()


